package com.example.canteen.service.impl;

import com.example.canteen.dao.CExceptionDao;
import com.example.canteen.dao.impl.CExceptionDaoImpl;
import com.example.canteen.domain.CException;
import com.example.canteen.service.CExceptionService;

import java.util.List;

public class CExceptionSerViceImpl implements CExceptionService {
    private CExceptionDao cExceptionDao = new CExceptionDaoImpl();
    @Override
    public boolean save(CException cException) {
        CException f = cExceptionDao.findById(cException.getEid());
        if(f!=null) {
            return false;
        }
        cExceptionDao.save(cException);
        return true;
    }


    @Override
    public CException findOne(int id) {
        return cExceptionDao.findById(id);
    }

    @Override
    public boolean update(CException cException) {
        if(cExceptionDao.update(cException)==0) {
            return false;
        }
        return true;
    }

    @Override
    public List<CException> findAll() {
        return cExceptionDao.findAll();
    }

    @Override
    public boolean delete(int id) {
        if (cExceptionDao.delete(id)==0) {
            return false;
        }
        return true;
    }
}
